package com.hq.bus.service.impl;

import com.hq.bus.mapper.AccountMapper;
import com.hq.bus.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional //事务控制
public class AccountServiceImpl implements IAccountService {
    @Autowired
    private AccountMapper accountMapper;

    @Override
    public int updateTransfer(String inName, String outName,double money) {
        try {
            //调⽤转⼊
            accountMapper.transferIn(inName, money);
            //调⽤转出
            accountMapper.transferOut(outName, money);
            return 0;
        } catch (Exception e) {
            System.out.println(e);
            return 1;
        }
    }
}